<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="/static/layui/css/layui.css">
</head>
<body>

<form class="layui-form"  id="pageSubmit">
    <input type="hidden" id="currentPage" name="currentPage">
    <div class="layui-form-item">
        <label class="layui-form-label" style="width: 100px">条件名称</label>
        <div class="layui-input-inline">
            <input type="text" name="con_name" placeholder="请输入条件名称" value="${params.con_name!''}"
                   class="layui-input">
        </div>

        <label class="layui-form-label" style="width: 100px">优惠类型</label>
        <div class="layui-input-inline">
            <select id="conType"  name="con_type">
                <option value="">请选择</option>
                <option value="满减">满减</option>
                <option value="立减">立减</option>
                <option value="折扣">折扣</option>
                <option value="返现">返现</option>
                <option value="积分">积分</option>
                <option value="包邮">包邮</option>
            </select>

        </div>

        <label class="layui-form-label" style="width: 100px">销售渠道类型</label>
        <div class="layui-input-inline">
            <select id="spSlType"  name="sp_sl_type">
                <option value="">请选择</option>
                <option value="热线">热线</option>
                <option value="网络">网络</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label" style="width: 100px">供应商</label>
        <div class="layui-input-inline">
            <select id="supId" name="sup_id">
                <option value="">请选择供应商</option>
            <#if list ? exists>
                <#list list as item>
                    <option value="${item.id!''}">${item.supName!''}</option>
                </#list>
            <#else >
            </#if>
            </select>
        </div>

        <label class="layui-form-label" style="width: 100px">使用环节</label>
        <div class="layui-input-inline">
            <select id="segment" name="segment">
                <option value="">请选择</option>
                <option value="下单后">下单后</option>
                <option value="支付">支付</option>
            </select>
        </div>

        <label class="layui-form-label" style="width: 100px">使用会员等级</label>
        <div class="layui-input-inline">
            <select id="conVipLevel" name="con_vip_level">
                <option value="">请选择</option>
                <option value="1">一级</option>
                <option value="2">二级</option>
                <option value="3">三级</option>
                <option value="4">四级</option>
                <option value="5">五级</option>
            </select>
        </div>

    </div>

    <div class="layui-form-item">

        <label class="layui-form-label" style="width: 100px">限定条件</label>
        <div class="layui-input-inline">
            <input type="text" name="con_value" placeholder="如：500"  value="${params.con_value!''}"
                   class="layui-input">
        </div>


        <label class="layui-form-label" style="width: 100px">是否可与其他促销条件共存</label>
        <div class="layui-input-inline">
            <select id="isOtherConCombine" name="is_other_con_combine">
                <option value="">请选择</option>
                <option value="y">是</option>
                <option value="n">否</option>
            </select>
        </div>


        <label class="layui-form-label" style="width: 100px">是否使用</label>
        <div class="layui-input-inline">
            <select id="isUsed" name="is_used">
                <option value="">请选择</option>
                <option value="y">使用</option>
                <option value="n">禁用</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="addSaleCdn">确认</button>
            <button type="reset" class="layui-btn layui-btn-primary" onclick="formReset()">重置</button>
        </div>
    </div>
</form>


<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>菜单管理</legend>
</fieldset>
<div class="layui-form">
    <table class="layui-table">
        <colgroup>
            <col width="100">
            <col width="100">
            <col width="100">
            <col width="100">
            <col width="100">
            <col width="100">
            <col width="100">
            <col width="100">
            <col width="100">
            <col width="100">
            <col width="100">
        </colgroup>
        <thead>
        <tr>
            <th>促销条件编号</th>
            <th>条件名称</th>
            <th>优惠类型</th>
            <th>销售渠道</th>
            <th>参与供应商</th>
            <th>使用环节</th>
            <th>适用会员等级</th>
            <th>限定条件</th>
            <th>是否与其他促销天剑共存</th>
            <th>是否可用</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>

        <#list list1 as item>
        <tr>
            <td>${item.con_no!''}</td>
            <td>${item.con_name!''}</td>
            <td>${item.con_type!''}</td>
            <td>${item.sp_sl_type!''}</td>
            <td>${item.sup_name!''}</td>
            <td>${item.segment!''}</td>
            <td>${item.con_vip_level!''}</td>
            <td>${item.con_value!''}</td>
            <td>
                <#if item.is_other_con_combine=='y'>使用
                <#else>禁用
                </#if>
            </td>
            <td>
                <#if item.is_used=='y'>使用
                <#else>禁用
                </#if>
            </td>

            <td>
                <button class="manageCpn layui-btn layui-btn-normal layui-btn-small" val="${item.con_no!''}"><i
                        class="layui-icon"></i>
            </td>
        </tr>
        </#list>
        </tbody>
    </table>
</div>
<div class="layui-form" >
    <span id="form_page"></span>&nbsp;共${page.total}条数据
</div>



<script type="text/javascript" src="/static/layui/layui.js"></script>
<script type="text/javascript">
    function formReset()
    {
        window.location.href = "/saleCdn/saleCndfManage";
    }
    layui.define(['element', 'form', 'layer', 'laypage', 'laydate'], function (exports) {
        var element = layui.element();
        var form = layui.form();
        var layer = layui.layer;
        var laypage = layui.laypage;
        var $ = layui.jquery;
        var laydate = layui.laydate;

        // 当前页
        var pindex = "${page.pageNum}";
        // 总页数
        var ptotalpages = "${page.pages}";
        // 数据总数
        var pcount = "${page.total}";

        // 分页
        laypage({
            // 页面上的id
            cont: 'form_page',
            //总页数
            pages: ptotalpages,
            //当前页
            curr: pindex,
            skip: true,
            jump: function (obj, first) {
                //设置当前页
                $("#currentPage").val(obj.curr);
                //防止无限刷新,
                //只有监听到的页面index 和当前页不一样是才出发分页查询
                if (obj.curr != pindex) {
                    $("#pageSubmit").submit();
                }else {
                    $("#currentPage").val(1);
                }
            }
        });

        //监听代金券修改事件
        $(".manageCpn").on("click", function () {
            var con_no = $(this).attr("val");
            layer.open({
                title: '管理菜单 - 惠买ivalue管理系统'
                , area: ['400px', '500px']
                //content内容为一个连接
                , type: 2
                , content: '/saleCdn/saleCndfbyconNo.do?con_no=' + con_no+''
            });
        });

        //带回页面的select参数进行动态赋值
        var sp_sl_type = "${params.sp_sl_type!''}";
        var sup_id = "${params.sup_id!''}";
        var con_type = "${params.con_type!''}";
        var segment = "${params.segment!''}";
        var con_vip_level = "${params.con_vip_level!''}";
        var is_other_con_combine = "${params.is_other_con_combine!''}";
        var is_used = "${params.is_used!''}"
        $("#conType").find("option[value ='" + con_type + "']").attr("selected", "selected");
        $("#spSlType").find("option[value ='" + sp_sl_type + "']").attr("selected", "selected");
        $("#supId").find("option[value ='" + sup_id + "']").attr("selected", "selected");
        $("#segment").find("option[value ='" + segment + "']").attr("selected", "selected");
        $("#conVipLevel").find("option[value ='" + con_vip_level + "']").attr("selected", "selected");
        $("#isOtherConCombine").find("option[value ='" + is_other_con_combine + "']").attr("selected", "selected");
        $("#isUsed").find("option[value ='" + is_used + "']").attr("selected", "selected");

        // 重新渲染页面
        form.render();
    });
</script>
</body>
</html>